package com.ay7.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * 微信授权登录（手工）
 * Created by wenjul
 * on 18/3/27 0027 17:37
 */
@RestController
@RequestMapping("/weixin")
@Slf4j
public class WexinController {


    /*
    * 1、域名解析
    * 2、获取code
    * 3、获取access_token
    * */
    @GetMapping("/auth")
    public void auth(@RequestParam("code") String code){
        log.info("进入auth方法");
        log.info("code={}",code);
        String url ="https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxf0e" +
                "81c3bee622d60&redirect_uri=https://www.baidu.com/2Foauth_response.php&" +
                "response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
        RestTemplate restTemplate = new RestTemplate();
        String response = restTemplate.getForObject(url, String.class);
        log.info("response={}", response);

    }
}
